let goodsModel = require("../models/goodsList").goodsList;

let goodsDAO = function (){};

goodsDAO.prototype = {
  //增
  save: function (json, callBack){
    let newGoods = new goodsModel(json);
    console.log(newGoods)
    newGoods.save(function (err){
      callBack(err);
    });
  },
  //删
  remove: function (json, callBack){
    goodsModel.remove(json, function (err){
      callBack(err);
    });
  },
  //改
  update: function (json, condition, callBack){
    goodsModel.update(json, condition, function (err){
      callBack(err);
    });
  },
  //查
  findOne: function (json, callBack){
    goodsModel.findOne(json, function (err, doc){
      callBack(err, doc);
    });
  },
  // 查询全部列表
  findAll: function ( callBack){
    goodsModel.find(function (err, doc){
      callBack(err, doc);
    });
  },
};

exports.goodsMethod = new goodsDAO();
